#pragma once

#include <iostream>
#include <vector>

#define DHGC DataHolderGarbageCollector::getInstance()

using namespace std;

class DataHolder;
class Referencer;

class DataHolderGarbageCollector {
public:
	
	static DataHolderGarbageCollector* getInstance();
	
	void addDataHolder(DataHolder* dataHolder);
	
	void addReferencer(Referencer* referencer);
	void removeReferencer(Referencer* refrencer);
	
	void collectGarbage(); // removes everything not referenced by Referencers
	void deleteAll(); // removes everything, no matter what (will break programs etc)
    
private:
	
	DataHolderGarbageCollector();
	
	static DataHolderGarbageCollector* s_instance;
	
	typedef vector<DataHolder*> DataHolders;
	DataHolders m_dataHolders;
	
	typedef vector<Referencer*> Referencers;
	Referencers m_referencers;
	
};